package com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.page.ConventPage;
import java.util.List;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.dto.TBarinSrerpReportDto;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.dto.SaveTBarinSrerpReportFormDataDto;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.vo.TBarinSrerpReportVo;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.vo.TBarinSrerpReportListVo;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.dto.TBarinSrerpReportListDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;

import org.springframework.web.bind.annotation.*;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.entity.TBarinSrerpReport;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.vo.TBarinSrerpReportVo;
import com.xjrsoft.module.customerTwo.barin.t_barin_srerp_report.service.ITBarinSrerpReportService;

/**
 *  控制器
 *
 * @author dongxinhang
 * @since 2024-06-18
 */
@RestController
@AllArgsConstructor
@RequestMapping("/t_barin_srerp_report")
@Api(value = "企业数据报表", tags = "企业数据报表接口")
public class TBarinSrerpReportController {


	private final ITBarinSrerpReportService tBarinSrerpReportService;


	/**
	 * 详情 
	 */
	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入tBarinSrerpReport")
	@SaCheckPermission(value = {"t_barin_srerp_report:view", "t_barin_srerp_report:modify"}, mode = SaMode.OR)
	public Response<TBarinSrerpReportVo> getFormData(@PathVariable String id) {
		// 主表数据
		TBarinSrerpReport tBarinSrerpReport = tBarinSrerpReportService.getById(id);
		TBarinSrerpReportVo tBarinSrerpReportVo = BeanUtil.copy(tBarinSrerpReport, TBarinSrerpReportVo.class);
		return Response.ok(tBarinSrerpReportVo);
	}

	/**
	 * 自定义分页 
	 */
	@GetMapping
	@ApiOperation(value = "分页", notes = "传入tBarinSrerpReport")
		public Response<PageOutput<TBarinSrerpReportListVo>> getPageList(TBarinSrerpReportListDto listDto) {
		IPage<TBarinSrerpReport> page = tBarinSrerpReportService.getPageList(listDto);
		List<TBarinSrerpReportListVo> records = BeanUtil.copyList(page.getRecords(), TBarinSrerpReportListVo.class);
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
	}

	/**
	 * 新增 
	 */
	@PostMapping
	@ApiOperation(value = "新增", notes = "传入tBarinSrerpReport")
	@SaCheckPermission("t_barin_srerp_report:add")
	public Response save(@RequestBody SaveTBarinSrerpReportFormDataDto formDto) {
		TBarinSrerpReportDto tBarinSrerpReportDto = formDto.getTBarinSrerpReportDto();
		TBarinSrerpReport tBarinSrerpReport = BeanUtil.copy(tBarinSrerpReportDto, TBarinSrerpReport.class);
		boolean isSuccess = tBarinSrerpReportService.addTBarinSrerpReport(tBarinSrerpReport);
		return Response.status(isSuccess);
	}

	/**
	 * 修改 
	 */
	@PutMapping("/{id}")
	@ApiOperation(value = "修改", notes = "传入tBarinSrerpReport")
	@SaCheckPermission("t_barin_srerp_report:modify")
	public Response update(@PathVariable String id, @RequestBody SaveTBarinSrerpReportFormDataDto formDto) {
		TBarinSrerpReportDto tBarinSrerpReportDto = formDto.getTBarinSrerpReportDto();
		TBarinSrerpReport tBarinSrerpReport = BeanUtil.copy(tBarinSrerpReportDto, TBarinSrerpReport.class);
		return Response.status(tBarinSrerpReportService.updateTBarinSrerpReport(id, tBarinSrerpReport));
	}



	/**
	 * 删除 
	 */
	@DeleteMapping("/{ids}")
	@ApiOperation(value = "删除", notes = "传入ids")
	@SaCheckPermission(value = {"t_barin_srerp_report:batchDelete", "t_barin_srerp_report:delete"}, mode = SaMode.OR)
	public Response remove(@ApiParam(value = "主键集合", required = true) @PathVariable String ids) {
		return Response.status(tBarinSrerpReportService.delete(ids));
	}


}
